package cn.tac.test.servlet.cheapter2;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author : tac
 * @since : 09/09/2017
 */
public class MyServletProcessor implements Processor {
    @Override
    public void process(HttpServletRequest request, HttpServletResponse response) {
        String servletName = ((Request)request).getServletName();
        Servlet servlet = ServletFactory.create(servletName);
        try {
            servlet.service(request, response);
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
